package com.example.myapplication.kotlin

const val url = "www.baidu.com"
fun main() {
    println(food("orange"))
    println(score(88))
    forTest()
}

fun food(name: String): String {
    return when (name) {
        "apple" -> "苹果1"
        "banana" -> "香蕉"
        "orange" -> "橘子"
        else -> "未知水果"
    }
}

fun score(score: Number): String {
    return when (score) {
        in 0..60 -> "不及格"
        in 60..80 -> "及格"
        in 80 until 101 -> "优秀"
        else -> "输入错误"
    }
}

fun forTest() {
    for (i in 1..10) {
        print(i)
    }
    println()
    for (i in 1 until 10) {
        print(i)
    }
    println()
    for (i in 10 downTo 1) {
        print(i)
    }
    println()
    for (i in 10 downTo 1 step 2) {
        print(i)
    }
    println()
    for (i in 1..10 step 2) {
        print(i)
    }
}